from __future__ import absolute_import
import solv

def calc_cookie_file(filename):
    chksum = solv.Chksum(solv.REPOKEY_TYPE_SHA256)
    chksum.add("1.1")
    chksum.add_stat(filename)
    return chksum.raw()

def calc_cookie_fp(fp):
    chksum = solv.Chksum(solv.REPOKEY_TYPE_SHA256)
    chksum.add_fp(fp)
    return chksum.raw()
    
import os, errno

def mkdir_p(path):
    try:
        os.makedirs(path)
    except OSError as exc: # Python >2.5
        if exc.errno == errno.EEXIST:
            pass
        else: raise
        
